package com.cardone.platform.common.function;

import com.cardone.context.function.Execution2Function;
import com.cardone.platform.usercenter.dto.UserDto;

import java.util.Map;

/**
 * Created by Administrator on 2015/3/23.
 */
public class OutputUserFunction implements Execution2Function<Map<String, Object>, Map<String, Object>, Object> {
    @Override
    public Map<String, Object> execution(Map<String, Object> parameterMap, Object returnData) {
        if(returnData == null){
            return parameterMap;
        }

        if(!(returnData instanceof UserDto)){
            return parameterMap;
        }

        UserDto user = (UserDto)returnData;

        parameterMap.put("userId",user.getId());
        parameterMap.put("userCode",user.getCode());
        parameterMap.put("userName",user.toString());
        parameterMap.put("id",user.getId());

        return parameterMap;
    }
}
